﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Data.SqlClient;
using System.Data;

namespace DAO
{
    public class KhachHangDAO : DataProvider
    {
        public ArrayList Get1KhachHang(string mathe)
        {
            connect();
            string sql = "SELECT * FROM dbo.KhachHang WHERE ma_the = '" + mathe + "'";
            adapter = new SqlDataAdapter(sql, connection);
            DataSet dataset = new DataSet();
            adapter.Fill(dataset);
            ArrayList arr = ConvertDataSetToArrayList(dataset);
            disconnect();
            return arr;
        }
        public int CongDiem(string mathe, int diem)
        {
            try
            {
                connect();
                string sql = "update dbo.KhachHang set diem_tich_luy = (select diem_tich_luy + " + diem.ToString() + "from dbo.KhachHang WHERE ma_the = '" + mathe + "') WHERE ma_the = '" + mathe + "'";
                executeNonQuery(sql);
                disconnect();
            }
            catch { return 0; }
            return 1;
        }
    }
}
